package com.ganinfo.sys.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ganinfo.common.Result;
import com.ganinfo.common.controller.BaseController;
import com.ganinfo.common.data.ParmaterUtils;
import com.ganinfo.common.data.TransmitMap;
import com.ganinfo.sys.model.SysRole;
import com.ganinfo.sys.service.ISysRoleService;

/**
 * @ClassName:   SysRoleController
 * @Description: [sys_role]控制类
 * @author:      ruikanwang
 * @date:        
 */
@Controller
public class SysRoleController extends BaseController {

    private final ISysRoleService service;

    @Autowired
    public SysRoleController(ISysRoleService service) {
        this.service = service;
    }

    /**
     * @Title:       getSysRoleList
     * @Description: 分页获取列表
     * @param：                    pageSize(每页记录数) pageNumber(页数) orderby(排序字段) orderbymethod(排序方式)
     * @return
     * @return:      String
     */
    @RequestMapping(value="/getSysRoleList",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})
    @ResponseBody
    public Result getSysRoleList(SysRole paramSysRole) {
    	Result returndate=null;
    	TransmitMap transmitMap = this.getTransmitMap();
    	List<String> paramCheckList = ParmaterUtils.paramCheck(transmitMap,"pageSize","pageNumber");
    	if(paramCheckList.size() > 0){
    		returndate=this.renderParamError(paramCheckList);
		}else{
			try {
				returndate=this.renderSuccess(service.getSysRoleList(transmitMap));
			} catch (Exception e) {
				returndate=this.renderError();
				e.printStackTrace();
			}
		}
        return returndate;
    }
    
    /**
     * @Title:       addSysRole
     * @Description: 添加
     * @param 
     * @return
     * @return:      String
     */
    @RequestMapping(value="/addSysRole",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})
    @ResponseBody
    public Result addSysRole(SysRole paramSysRole) {
    	Result returndate=null;
    	try {
    		if(service.addSysRole(paramSysRole)){
    			returndate=this.renderSuccess(null);
    		}else{
    			returndate=this.renderError();
    		}
		} catch (Exception e) {
			returndate=this.renderError();
			e.printStackTrace();
		}
        return returndate;
    }
    
    /**
     * @Title:       updateSysRole
     * @Description: 更新
     * @param        paramSysRole
     * @return
     * @return:      String
     */
    @RequestMapping(value="/updateSysRole",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})
    @ResponseBody
    public Result updateSysRole(SysRole paramSysRole) {
    	Result returndate=null;
    	try {
    		if(service.updateSysRole(paramSysRole)){
    			returndate=this.renderSuccess(null);
    		}else{
    			returndate=this.renderError();
    		}
		} catch (Exception e) {
			returndate=this.renderError();
			e.printStackTrace();
		}
        return returndate;
    }
    
    /**
     * @Title:       deleteSysRole
     * @Description: 删除
     * @param paramSysRole
     * @return
     * @return:      String
     */
    @RequestMapping(value="/deleteSysRole",method=RequestMethod.POST,produces={"application/json;charset=UTF-8"})
    @ResponseBody
    public Result deleteSysRole(SysRole paramSysRole) {
    	Result returndate=null;
    	try {
    		if(service.deleteSysRole(paramSysRole)){
    			returndate=this.renderSuccess(null);
    		}else{
    			returndate=this.renderError();
    		}
		} catch (Exception e) {
			returndate=this.renderError();
			e.printStackTrace();
		}
        return returndate;
    }
}
